class Queue():
    def __init__(self):
        self.stack_input = []
        self.stack_output = []

    def size(self):
        # 计算队列长度
        return len(self.stack_input) + len(self.stack_output)

    def append(self, e):
        # 向队列添加元素e
        self.stack_input.append(e)

    def pop_top(self):
        # 弹出队列元素
        if self.size() > 0:
            if not self.stack_output:
                # 将入栈的数据全部转换到出栈
                while self.stack_input:
                    self.stack_output.append(self.stack_input.pop())
            return self.stack_output.pop()
        else:
            raise IndexError("队列为空")


test = Queue()
test.append(1)
test.append(2)
test.append(3)
print(test.pop_top())
print(test.pop_top())
test.append(4)
test.append(5)
print(test.pop_top())
print(test.pop_top())
print(test.pop_top())
print(test.pop_top())